﻿
@{
    ViewBag.Title = "个人推广详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="main-box">
            <header class="main-box-header clearfix">
                <h2>个人推广详情</h2>
            </header>
            <div class="main-box-body clearfix">
                <div class="row">
                
                        <div class="col-lg-12" style="margin-top:20px;margin-bottom:20px">
                            <button type="button" onclick="StartDate(1)" class="btn btn-success btn-sm">本月</button>

                            <button type="button" onclick="StartDate(2)" class="btn btn-primary btn-sm">上月</button>

                            <button type="button" onclick="StartDate(3)" class="btn btn-success btn-sm">昨天</button>

                            <button type="button" onclick="StartDate(4)" class="btn btn-info btn-sm">最近7天</button>

                            <button type="button" onclick="StartDate(5)" class="btn btn-danger btn-sm">最近15天</button>

                            <button type="button" onclick="StartDate(6)" class="btn btn-danger  btn-facebook btn-sm">最近30天</button>
                        </div>
                        <div class="col-lg-6">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-calendar-o"></i></span>
                                        <input type="text" class="form-control" id="Starttime">
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="col-lg-6">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="input-group ">
                                        <span class="add-on input-group-addon"><i class="fa fa-calendar-o"></i></span>
                                        <input type="text" class="form-control" id="Endtime">

                                    </div>

                                </div>
                            </div>
                        </div>
                        <div class="col-lg-12">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="controls ">
                                        <select class="form-control" id="tgw">
                                            <option value="0">不限定推广类型</option>
                                            <option value="1">网站推广</option>
                                            <option value="2">微信推广</option>
                                            <option value="3">QQ推广</option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="col-lg-6">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-recycle"></i></span>
                                        <input type="text" class="form-control" placeholder="联盟账号成员ID" id="aliID">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="input-group ">
                                        <span class="add-on input-group-addon"><i class="fa fa-user"></i></span>
                                        <input type="text" class="form-control" placeholder="终端推广用户账号" id="userid">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-12">
                            <div class="row">
                                <div class="form-group col-md-12">
                                    <div class="controls ">
                                        <button type="button" id="search" class="btn btn-lg btn-success   ">
                                            &nbsp; &nbsp; 查询&nbsp; &nbsp;
                                        </button>
                                    </div>
                                </div>
                            </div>

                        </div>
                     
</div>
                <div class="table-responsive">
                    <table id="acc_tb" class="table ">
                        <thead>
                            <tr>
                                <th data-sortable="true" data-formatter="CreateDate">日期</th>
                                <th data-sortable="true" data-formatter="PromotionType">类型</th>
                                <th data-field="ClickNum">点击</th>
                                <th data-field="PayNum">订单</th>
                                <th data-field="Estimate">预估</th>
                                <th data-field="Income">结算</th>
                                <th data-field="AlimamaID">联盟账号</th>
                                <th data-field="PromotionBit">推广者</th>
                            </tr>
                        </thead>
                    </table>
                </div>

            </div>
        </div>
    </div>
</div>



@section Scripts{

    <link rel="stylesheet" type="text/css" href="/css/libs/dataTables.fixedHeader.css">
    <link rel="stylesheet" type="text/css" href="/css/libs/dataTables.tableTools.css">
    <script src="~/Scripts/plugins/bootstrap.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="~/Scripts/sys/lib/common_raw.js"></script>
    <script src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script type="text/javascript">
        function initAcTable()
        {
            $('#acc_tb').bootstrapTable('destroy');
            common.initAcTable("acc_tb", "toolbar", "post", "/GetIncome.html",
                function (data)
                {
                    if (!data.State) {
                        common.msg(data.Message, 1);
                    }
                },
                function (e) { },
                true, true, false, 20, 1, "[10,20,30,50]", { Starttime: $("#Starttime").val(), Endtime: $("#Endtime").val(), tgw: $("#tgw").val(), aliID: $("#aliID").val(), userid: $("#userid").val() });
        }
        $(document).ready(function ()
        {
            $("#Starttime").val(Get7day(-29));
            $("#Endtime").val(formatDate(now));
            $("#search").bind("click", function () {
                var load_index3 = layer.load(0, { shade: 0.6 });
                initAcTable();
                layer.close(load_index3);
            });
           // initAcTable();

        });
        var now = new Date(); 
        var nowDay = now.getDate(); 
        var nowMonth = now.getMonth(); 
        var nowYear = now.getFullYear(); 
        var lastMonthDate = new Date();
        lastMonthDate.setDate(1);
        lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
        var lastYear = lastMonthDate.getYear();
        var lastMonth = lastMonthDate.getMonth();

        function formatDate(date)
        {
            var myyear = date.getFullYear();
            var mymonth = date.getMonth() + 1;
            var myweekday = date.getDate();

            if (mymonth < 10) {
                mymonth = "0" + mymonth;
            }
            if (myweekday < 10) {
                myweekday = "0" + myweekday;
            }
            return (myyear + "-" + mymonth + "-" + myweekday);
        }
      
        function getMonthStartDate()
        {
            var monthStartDate = new Date(nowYear, nowMonth, 1);
          
            return nowYear + "-" + (nowMonth+1) + "-" + "1";
        }
       
        function GetYesterday() {
            var monthEndDate = new Date(nowYear, nowMonth, nowDay - 1);
            return formatDate(monthEndDate);
        }
        function Get7day(day) {
            var monthEndDate = new Date(nowYear, nowMonth, nowDay +day);
            return formatDate(monthEndDate);
        }
       
        function getMonthEndDate() {
            var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
            return formatDate(monthEndDate);
        }
       
        function getLastMonthStartDate() {
            var lastMonthStartDate = new Date(nowYear, lastMonth, 1);
            return formatDate(lastMonthStartDate);
        }
       
        function getMonthDays(myMonth) {
            var monthStartDate = new Date(nowYear, myMonth, 1);
            var monthEndDate = new Date(nowYear, myMonth + 1, 1);
            var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
            return days;
        }
     
        function getLastMonthEndDate() {
            var lastMonthEndDate = new Date(nowYear, lastMonth, getMonthDays(lastMonth));
           
            return formatDate(lastMonthEndDate);
        }

        function StartDate(obj) {
            switch (obj){
                case 1:
                    $("#Starttime").val(getMonthStartDate());
                    $("#Endtime").val(formatDate(now));
                    break;
                case 2:
                    $("#Starttime").val(getLastMonthStartDate());
                    $("#Endtime").val(getLastMonthEndDate());
                    break;
                case 3:
                    $("#Starttime").val(GetYesterday());
                    $("#Endtime").val(GetYesterday());
                    break;
                case 4: 
                    $("#Starttime").val(Get7day(-6));
                    $("#Endtime").val(formatDate(now));
                    break;
                case 5:
                    $("#Starttime").val(Get7day(-14));
                    $("#Endtime").val(formatDate(now));
                    break;
                case 6:
                    $("#Starttime").val(Get7day(-29));
                    $("#Endtime").val(formatDate(now));
                    break;
            }
        }

        function CreateDate(index, row) {
            var birthdayMilliseconds = parseInt(row.CreateDate.replace(/\/Date\(/igm, ""));
            return new Date(birthdayMilliseconds).Format("yyyy-MM-dd");
        }
        function PromotionType(index, row) {
            return row.PromotionType == 1 ? "网站推广" : (row.PromotionType == 2?"微信推广":"QQ推广");
        }
       

    </script>
}








